package com.wms.controller;

import com.wms.common.CallBack;
import com.wms.common.Response;
import com.wms.domain.*;
import com.wms.service.information.InformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "基础信息")
@RequestMapping(path = "/Information/")
@RestController
public class Information {
    @Autowired
    private InformationService informationService;
    @ApiOperation(value="编辑公司信息")
    @RequestMapping(path="addOrUpdate",method= RequestMethod.POST)
    public Response addOrUpdate(@RequestBody CompanyDomain companyDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.add(companyDomain);
            }
        }.execute();

    }

    @ApiOperation(value="删除公司信息")
    @RequestMapping(path="deleteCompany",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response deleteCompany(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.delete(id);
            }
        }.execute();

    }

    @ApiOperation(value="查询公司信息")
    @RequestMapping(path="getCompanyPage",method= RequestMethod.POST)
    public Response getCompanyPage(@RequestBody CompanyDomain companyDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.getCompanyPage(companyDomain);
            }
        }.execute();
    }





    //Clients
    @ApiOperation(value="编辑往来单位")
    @RequestMapping(path="addOrUpdateClients",method= RequestMethod.POST)
    public Response addOrUpdateClients(@RequestBody ClientsDomain clientsDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.addOrUpdateClients(clientsDomain);
            }
        }.execute();

    }

    @ApiOperation(value="删除往来单位")
    @RequestMapping(path="deleteClients",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response deleteClients(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.deleteClients(id);
            }
        }.execute();

    }

    @ApiOperation(value="查询往来单位")
    @RequestMapping(path="getClientsPage",method= RequestMethod.POST)
    public Response getClientsPage(@RequestBody ClientsDomain clientsDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.getClientsPage(clientsDomain);
            }
        }.execute();

    }

    //Storage
    @ApiOperation(value="编辑仓库信息")
    @RequestMapping(path="addOrUpdateStorage",method= RequestMethod.POST)
    public Response addOrUpdateStorage(@RequestBody StorageDomain storageDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.addOrUpdateStorage(storageDomain);
            }
        }.execute();
    }

    @ApiOperation(value="删除仓库")
    @RequestMapping(path="deleteStorage",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response deleteStorage(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.deleteStorage(id);
            }
        }.execute();
    }

    @ApiOperation(value="查询仓库")
    @RequestMapping(path="getStoragePage",method= RequestMethod.POST)
    public Response getStoragePage(@RequestBody StorageDomain storageDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.getStoragePage(storageDomain);
            }
        }.execute();

    }


    //StoreArea
    @ApiOperation(value="编辑库区信息")
    @RequestMapping(path="addOrUpdateStoreArea",method= RequestMethod.POST)
    public Response addOrUpdateStoreArea(@RequestBody StoreAreaDomain storeAreaDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.addOrUpdateStoreArea(storeAreaDomain);
            }
        }.execute();
    }

    @ApiOperation(value="删除库区")
    @RequestMapping(path="deleteStoreArea",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response deleteStoreArea(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.deleteStoreArea(id);
            }
        }.execute();
    }

    @ApiOperation(value="查询库区")
    @RequestMapping(path="getStoreAreaPage",method= RequestMethod.POST)
    public Response getStoreAreaPage(@RequestBody StoreAreaDomain storeAreaDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.getStoreAreaPage(storeAreaDomain);
            }
        }.execute();

    }


    //StoreLocation
    @ApiOperation(value="编辑库位信息")
    @RequestMapping(path="addOrUpdateStoreLocation",method= RequestMethod.POST)
    public Response addOrUpdateStoreLocation(@RequestBody StoreLocationDomain storeLocationDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.addOrUpdateStoreLocation(storeLocationDomain);
            }
        }.execute();
    }

    @ApiOperation(value="删除库位")
    @RequestMapping(path="deleteStoreLocation",method= RequestMethod.POST)
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public Response deleteStoreLocation(final Long id){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.deleteStoreLocation(id);
            }
        }.execute();
    }

    @ApiOperation(value="查询库位")
    @RequestMapping(path="getStoreLocationPage",method= RequestMethod.POST)
    public Response getStoreLocationPage(@RequestBody StoreLocationDomain storeLocationDomain){
        return new CallBack() {
            @Override
            protected Object run() {
                return informationService.getStoreLocationPage(storeLocationDomain);
            }
        }.execute();
    }
}
